from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import sys

class IndexPage(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.draw()
    def draw(self):
        #基本组件
        self.index_btn = QPushButton("首页")
        self.brief_btn = QPushButton("简介")
        self.d2_btn = QPushButton("2D攻击")
        self.d3_btn = QPushButton("3D攻击")
        self.search_line = QLineEdit()
        #简介框
        self.brief_line = QLineEdit()
        #主体布局
        self.my_layout = QVBoxLayout()
        #顶部布局
        self.top_layout = QHBoxLayout()
        self.top_widget = QWidget()
        self.setLayout(self.my_layout)
        self.draw_top()
        self.my_layout.addWidget(self.top_widget)
        self.my_layout.addWidget(self.brief_line)
    def draw_top(self):
        widget = self.top_widget
        widget.setLayout(self.top_layout)
        self.top_layout.addWidget(self.index_btn)
        self.top_layout.addWidget(self.brief_btn)
        self.top_layout.addWidget(self.d2_btn)
        self.top_layout.addWidget(self.d3_btn)
        self.top_layout.addWidget(self.search_line)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = IndexPage()
    window.show()
    sys.exit(app.exec_())